CMAKE_MINIMUM_REQUIRED (VERSION 3.10)


SET ( RBDL_ADDON_BALANCE_TESTS_VERSION_MAJOR 0 )
SET ( RBDL_ADDON_BALANCE_TESTS_VERSION_MINOR 0 )
SET ( RBDL_ADDON_BALANCE_TESTS_VERSION_PATCH 0 )

SET ( RBDL_ADDON_BALANCE_TESTS_VERSION 
	${RBDL_ADDON_BALANCE_TESTS_VERSION_MAJOR}.${RBDL_ADDON_BALANCE_TESTS_VERSION_MINOR}.${RBDL_ADDON_BALANCE_TESTS_VERSION_PATCH}
)


PROJECT (RBDL_BALANCE_TESTS VERSION ${RBDL_ADDON_BALANCE_TESTS_VERSION})


# Look for catch2
FIND_PACKAGE(Catch2 3 REQUIRED)


SET ( BALANCE_TESTS_SRCS
	testBalanceToolkit.cc
	../balance.h
	../BalanceToolkit.h
	../BalanceToolkit.cc
	)


SET_TARGET_PROPERTIES ( ${PROJECT_EXECUTABLES} PROPERTIES
  LINKER_LANGUAGE CXX
)

ADD_EXECUTABLE ( rbdl_balance_tests ${BALANCE_TESTS_SRCS} )

SET_TARGET_PROPERTIES ( rbdl_balance_tests PROPERTIES
	LINKER_LANGUAGE CXX
	OUTPUT_NAME balance_tests
	)

SET (RBDL_LIBRARY rbdl)
IF (RBDL_BUILD_STATIC)
	SET (RBDL_LIBRARY rbdl-static)
ENDIF (RBDL_BUILD_STATIC)

TARGET_LINK_LIBRARIES ( rbdl_balance_tests
  Catch2::Catch2WithMain
  ${RBDL_LIBRARY}
  )
	
OPTION (RUN_AUTOMATIC_TESTS "Perform automatic tests after compilation?" OFF)

IF (RUN_AUTOMATIC_TESTS)
ADD_CUSTOM_COMMAND (TARGET rbdl_balance_tests
	POST_BUILD
	COMMAND ./balance_tests
	COMMENT "Running automated addon balance tests..."
	)
ENDIF (RUN_AUTOMATIC_TESTS)
